﻿using System;
using System.Drawing;
using EmbeddedSharp.Core;

namespace Zove.Desktop.Function
{
    public class DisplayNode : FuncNode
    {
        public DisplayNode()
            : base("display")
        {
        }

        public override object Evaluate()
        {
            int length = Parameters.Count;
            if (length < 1)
            {
                throw new ArgumentException("");
            }

            Image image = Parameters[length - 1].Evaluate() as Image;
            if (image != null)
            {
                DisplayImageForm form = new DisplayImageForm(image);
                DesktopFormContext.Context.Main.ShowWindow(form);
            }

            return string.Empty;
        }
    }
}
